package cn.yunhe.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 日期工具类
 * @author QPH
 *
 */
public class DateUtil {
	private static final SimpleDateFormat SDF_DATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private static final SimpleDateFormat SDF_DATE_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static String dateTimeToString(Date date) {
		return SDF_DATE_TIME.format(date);
	}

	public static Date stringToDateTime(String dateStr) throws ParseException {
		return SDF_DATE_TIME.parse(dateStr);
	}

	public static String dateToString(Date date) {
		return SDF_DATE.format(date);
	}

	public static Date stringToDate(String dateStr, String string) throws ParseException {
		return SDF_DATE.parse(string);
	}
}
